/*
 * at24c16.c
 *
 *  Created on: 2014-3-11
 *      Author: Rome
 */

#include "at24c16.h"
#include "iic.h"
#include "unistd.h"

void AcquireInitialInformation(alt_u8* pbuf)
{
	// initial gate way ip

	At24c16Read(0, pbuf, 18);

//	*pbuf = 192;
//	*(pbuf + 1) = 168;
//	*(pbuf + 2) = 12;
//	*(pbuf + 3) = 1;
//
//	// initial mask
//	*(pbuf + 4) = 255;.......................................
//	*(pbuf + 5) = 255;
//	*(pbuf + 6) = 255;
//	*(pbuf + 7) = 0;
//
//	// initial mac address
//	*(pbuf + 8) = 0;
//	*(pbuf + 9) = 1;
//	*(pbuf + 10) = 2;
//	*(pbuf + 11) = 3;
//	*(pbuf + 12) = 4;
//	*(pbuf + 13) = 5;
//
//	// initial IP
//	*(pbuf + 14) = 192;
//	*(pbuf + 15) = 168;
//	*(pbuf + 16) = 12;
//	*(pbuf + 17) = 200;

	return;
}

void At24c16Read(alt_u16 Addr, alt_u8* Pbuf, alt_u16 length)
{
	alt_u32 i;
	for(i = 0; i < length; i ++)
	{
		*(Pbuf + i) = AT24C16_R((unsigned short)(Addr + i));
	}
	return;
}

void At24c16Write(alt_u16 Addr, alt_u8* Pbuf, alt_u16 length)
{
	alt_u32 i;
	alt_u8 WrTemp = 0;
	for(i = 0; i < length; i ++)
	{
		WrTemp = *(Pbuf + i);
		AT24C16_W((unsigned short)(Addr + i), WrTemp);
	}
	return;
}

